//
//  FKWithdrawDetailCell.m
//  WanTao
//
//  Created by Macbook Pro on 2019/3/29.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKWithdrawDetailCell.h"
#import "FKWithdrawDetail.h"

@interface FKWithdrawDetailCell ()

@property (nonatomic, weak) UILabel *titleLabel;
@property (nonatomic, weak) UILabel *statusLabel;

@property (nonatomic, weak) UILabel *amountLabel;
@property (nonatomic, weak) UILabel *addTimeLabel;
@property (nonatomic, weak) UILabel *checkTimeLabel;
@property (nonatomic, weak) UILabel *bankLabel;
@property (nonatomic, weak) UILabel *bankNumLabel;

@property (nonatomic, weak) UILabel *checkTimeTitle;
@property (nonatomic, weak) UILabel *bankTitle;
@property (nonatomic, weak) UILabel *bankNumTitle;

@end

@implementation FKWithdrawDetailCell

- (void)setupSubviews
{
    [super setupSubviews];
    [self.contentView clipsToBounds];
    
    [self.contentView clipsToBounds];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UILabel *titleLabel = [UILabel fk_labelWithFont:fk_adjustFont(16) textColor:fkColor333333];
    [self.contentView addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
    UILabel *statusLabel = [UILabel fk_labelWithFont:fk_adjustFont(10) textColor:nil textAlignment:NSTextAlignmentCenter];
    [self.contentView addSubview:statusLabel];
    self.statusLabel = statusLabel;
    [statusLabel fk_viewCornerRadius:2 borderWidth:0 borderColor:nil];
    
    NSArray *titles = @[@"提现金额:", @"申请时间:", @"审核时间:", @"开户行:", @"账号:"];
    UILabel *lastLabel;
    for (NSInteger index = 0; index < titles.count; index++) {
        UILabel *leftLabel = [UILabel fk_labelWithFont:fk_adjustFont(12) textColor:fkColor666666 text:titles[index]];
        [self.contentView addSubview:leftLabel];
        leftLabel.tag = 20 + index;
//        leftLabel.backgroundColor = [UIColor redColor];
        
        UILabel *rightLabel = [UILabel fk_labelWithFont:fk_adjustFont(12) textColor:fkColor666666];
        [self.contentView addSubview:rightLabel];
        rightLabel.tag = 10 + index;
        
        if (index == 0) {
            [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(titleLabel);
                make.top.equalTo(titleLabel.mas_bottom);
                make.height.offset(fk_adjustW(20));
            }];
        } else {
            [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
                make.left.equalTo(titleLabel);
                make.top.equalTo(lastLabel.mas_bottom);
                make.height.offset(fk_adjustW(20));
            }];
        }
        lastLabel = leftLabel;
        [rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(leftLabel.mas_right).offset(6);
            make.centerY.equalTo(leftLabel);
        }];
    }
    self.checkTimeTitle = [self.contentView viewWithTag:22];
    self.bankTitle = [self.contentView viewWithTag:23];
    self.bankNumTitle = [self.contentView viewWithTag:24];
    
    self.amountLabel = [self.contentView viewWithTag:10];
    self.addTimeLabel = [self.contentView viewWithTag:11];
    self.checkTimeLabel = [self.contentView viewWithTag:12];
    self.bankLabel = [self.contentView viewWithTag:13];
    self.bankNumLabel = [self.contentView viewWithTag:14];
    
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(12);
        make.top.offset(fk_adjustW(10));
    }];
    [statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(titleLabel.mas_right).offset(8);
        make.centerY.equalTo(titleLabel);
        make.width.offset(fk_adjustW(48));
        make.height.offset(fk_adjustW(14));
    }];
}

- (void)setData:(id)data
{
    [super setData:data];
    
    FKWithdrawDetail *model = data;
    
    self.titleLabel.text = model.desc;
    self.statusLabel.text = model.statusName;
    self.statusLabel.textColor = model.statusTitleColor;
    self.statusLabel.backgroundColor = model.statusBgColor;
    
    self.amountLabel.text = model.moneyStr;
    self.addTimeLabel.text = model.addTime;
    self.checkTimeLabel.text = model.examineTime ? : @"--";
    self.bankLabel.text = model.bank_info[@"name"];
    self.bankNumLabel.text = model.bank_info[@"bank_number"];
    
    if ([model.withdraw_type isEqualToString:@"1"]) { // 微信提现
        self.bankTitle.hidden = true;
        self.bankNumTitle.hidden = true;
    } else {
        self.bankTitle.hidden = false;
        self.bankNumTitle.hidden = false;
    }
}


@end
